/* 全局样式 */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  line-height: 1.6;
  color: #333;
  background-color: #f5f5f5;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 30px;
  padding-bottom: 10px;
  border-bottom: 1px solid #ddd;
}

h1, h2, h3 {
  color: #2c3e50;
}

/* 按钮样式 */
.btn {
  display: inline-block;
  padding: 8px 16px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  text-decoration: none;
  transition: background-color 0.3s, transform 0.1s;
}

.btn:hover {
  transform: translateY(-2px);
}

.btn-primary {
  background-color: #3498db;
  color: white;
}

.btn-primary:hover {
  background-color: #2980b9;
}

.btn-secondary {
  background-color: #7f8c8d;
  color: white;
}

.btn-secondary:hover {
  background-color: #6c7a7a;
}

.btn-danger {
  background-color: #e74c3c;
  color: white;
}

.btn-danger:hover {
  background-color: #c0392b;
}

/* 表单样式 */
.stock-form {
  background-color: white;
  padding: 20px;
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  margin-bottom: 30px;
}

/* 股票列表标题区域 */
.stock-list-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.stock-list-header h2 {
  margin: 0;
}

#refresh-btn {
  font-size: 14px;
  padding: 8px 16px;
  min-width: 100px;
}

#refresh-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

#refresh-btn:disabled:hover {
  transform: none;
  background-color: #7f8c8d;
}

.form-group {
  margin-bottom: 15px;
}

label {
  display: block;
  margin-bottom: 5px;
  font-weight: 600;
}

input[type="text"] {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 16px;
}

/* 股票列表样式 */
.stock-list {
  margin-bottom: 30px;
}

.stock-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
}

.stock-card {
  background-color: white;
  border-radius: 8px;
  padding: 20px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  transition: transform 0.3s;
  cursor: pointer;
}

.stock-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.stock-card h3 {
  margin-bottom: 10px;
  border-bottom: 1px solid #eee;
  padding-bottom: 10px;
}

.stock-card .price-info {
  display: flex;
  justify-content: space-between;
  margin-bottom: 15px;
}

.stock-card .current-price {
  font-size: 24px;
  font-weight: bold;
}

.stock-card .price-change {
  font-size: 18px;
}

.stock-card .price-details {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.stock-card .detail-item {
  display: flex;
  justify-content: space-between;
}

.stock-card .label {
  color: #7f8c8d;
  font-weight: 600;
}

.stock-card .actions {
  margin-top: 15px;
  display: flex;
  justify-content: flex-end;
}

/* 详情卡片样式 */
.detail-card {
  cursor: default;
  margin-bottom: 30px;
}

.detail-card:hover {
  transform: none;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

/* 价格表格样式 */
.price-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 20px;
  background-color: white;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  border-radius: 8px;
  overflow: hidden;
}

.price-table th,
.price-table td {
  padding: 12px 15px;
  text-align: right;
}

.price-table th {
  background-color: #3498db;
  color: white;
  font-weight: 600;
  text-align: center;
}

.price-table tr:nth-child(even) {
  background-color: #f9f9f9;
}

.price-table tr:hover {
  background-color: #f1f1f1;
}

/* 涨跌颜色 */
.up {
  color: #e74c3c; /* 红色表示上涨 */
}

.down {
  color: #2ecc71; /* 绿色表示下跌 */
}

/* 模态框样式 */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  overflow: auto;
}

.modal-content {
  background-color: white;
  margin: 10% auto;
  padding: 20px;
  border-radius: 8px;
  width: 80%;
  max-width: 800px;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
  animation: modalFadeIn 0.3s;
}

@keyframes modalFadeIn {
  from { opacity: 0; transform: translateY(-50px); }
  to { opacity: 1; transform: translateY(0); }
}

.close {
  color: #aaa;
  float: right;
  font-size: 28px;
  font-weight: bold;
  cursor: pointer;
}

.close:hover {
  color: #333;
}

/* 加载动画 */
.loading {
  text-align: center;
  padding: 20px;
  color: #7f8c8d;
}

.loading:after {
  content: "";
  display: inline-block;
  width: 20px;
  height: 20px;
  margin-left: 10px;
  border: 3px solid #ddd;
  border-radius: 50%;
  border-top-color: #3498db;
  animation: spin 1s linear infinite;
  vertical-align: middle;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* 页脚样式 */
footer {
  text-align: center;
  margin-top: 50px;
  padding-top: 20px;
  border-top: 1px solid #ddd;
  color: #7f8c8d;
}

/* 响应式设计 */
@media (max-width: 768px) {
  .container {
    padding: 10px;
  }
  
  .stock-cards {
    grid-template-columns: 1fr;
    gap: 15px;
  }
  
  .stock-card {
    padding: 15px;
  }
  
  .stock-card h3 {
    font-size: 18px;
  }
  
  .stock-card .current-price {
    font-size: 20px;
  }
  
  .stock-card .price-change {
    font-size: 16px;
  }
  
  .stock-card .price-details {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  
  .stock-card .detail-item {
    font-size: 14px;
  }
  
  .stock-card .actions {
    margin-top: 10px;
    gap: 10px;
  }
  
  .btn {
    padding: 10px 16px;
    font-size: 16px;
    min-height: 44px; /* 触摸友好的最小高度 */
  }
  
  /* 表格响应式 */
  .table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  
  .price-table {
    font-size: 12px;
    min-width: 800px; /* 确保表格内容不被压缩 */
  }
  
  .price-table th,
  .price-table td {
    padding: 6px 4px;
    white-space: nowrap;
  }
  
  .modal-content {
    width: 95%;
    margin: 5% auto;
    padding: 15px;
  }
  
  /* 表单优化 */
  input[type="text"] {
    font-size: 16px; /* 防止iOS缩放 */
    padding: 12px;
  }
  
  .form-group {
    margin-bottom: 20px;
  }
  
  /* 头部优化 */
  header {
    flex-direction: column;
    text-align: center;
    gap: 10px;
  }
  
  h1 {
    font-size: 24px;
  }
  
  h2 {
    font-size: 20px;
  }
}

/* 小屏幕设备优化 */
@media (max-width: 480px) {
  .container {
    padding: 8px;
  }
  
  .stock-form {
    padding: 15px;
  }
  
  .stock-card {
    padding: 12px;
  }
  
  .stock-card .current-price {
    font-size: 18px;
  }
  
  .stock-card .price-change {
    font-size: 14px;
  }
  
  .price-table {
    font-size: 11px;
  }
  
  .price-table th,
  .price-table td {
    padding: 4px 2px;
  }
  
  .modal-content {
    margin: 2% auto;
    padding: 10px;
  }
  
  h1 {
    font-size: 20px;
  }
  
  h2 {
    font-size: 18px;
  }
}

/* 触摸设备优化 */
@media (hover: none) and (pointer: coarse) {
  .btn {
    min-height: 44px;
    padding: 12px 20px;
  }
  
  .stock-card:hover {
    transform: none;
  }
  
  .stock-card:active {
    transform: scale(0.98);
    transition: transform 0.1s;
  }
  
  .btn:hover {
    transform: none;
  }
  
  .btn:active {
    transform: scale(0.95);
  }
}